<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>闭包三秒之后打印索引号</title>
	</head>
	<body>
		<ul>
			<li>1</li>
			<li>2</li>
			<li>3</li>
		</ul>
		
		<script type="text/javascript">
			//闭包实现三秒之后获取索引号
			var lis = document.querySelectorAll('ul li');
			for(var i = 0; i < lis.length; i++) {
				(function(i){
					lis[i].index = i;
					setTimeout(function() {
						console.log(lis[i].index)
					},3000)
				})(i);
			}
		</script>
	</body>
</html>
